package sb.ejb;

import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import sb.entity.Partner;

/**
 *
 * @author Pavel
 */
@Singleton
@Startup
public class ConfigBean {
	
	@PersistenceContext
	EntityManager em;
	
	private void createPartner(String code, String name) {
		Partner partner = new Partner();
		partner.setCode(code);
		partner.setName(name);
		em.persist(partner);
	}
	
	//@PostConstruct
	public void createData() {
		// Create sample data
		createPartner("0001", "Partner #1");
		createPartner("0002", "Partner #2");
		createPartner("0003", "Partner #3");
		createPartner("0004", "Partner #4");
		createPartner("0005", "Partner #5");
		createPartner("0006", "Partner #6");
		createPartner("0007", "Partner #7");
		createPartner("0008", "Partner #8");
		createPartner("0009", "Partner #9");
	}
}
